@extends('admin::layouts.master')
@section('title')
    检车站规格列表
@endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">

                    <div class="layui-card-body layui_overflow_y">

                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>ID</th>
                                <th>规格名称</th>
                            </tr>
                            </thead>
                            <tbody class="x-cate">
                            <?php
                            $n_xuhao = 0;
                            ?>
                            @foreach($arr_data as $key=>$value)
                                <?php
                                if($value["pid"] == 0){
                                    $n_xuhao++;
                                }
                                ?>
                                <tr cate-id='{{$value["id"]}}' fid='{{$value["pid"]}}' >
                                    <td>
                                        @if($value["pid"] === 0)
                                            {{$n_xuhao}}
                                        @endif
                                    </td>
                                    <td>
                                        {{$value["id"]}}
                                    </td>
                                    <td>
                                        {{$value["pre_ico"]}}
                                        @if($value['_child'] === 1)
                                            <i class="layui-icon x-show" status='true'>&#xe623;</i>

                                        @else
                                            &nbsp;&nbsp;&nbsp;&nbsp;
                                        @endif
                                        {{$value["name"]}}
                                    </td>

                                </tr>

                            @endforeach
                            @if(count($arr_data) == 0)
                                <tr>
                                    <td colspan="66" style="text-align: center">暂无数据</td>

                                </tr>

                            @endif
                            </tbody>
                        </table>
                    </div>
                    {{--         <div class="layui-card-body ">
                                 <div class="page">
                                     {{$page_link}}
                                 </div>

                                 --}}{{--     <div class="page">
                                          <div>
                                              <a class="prev" href="">&lt;&lt;</a>
                                              <a class="num" href="">1</a>
                                              <span class="current">2</span>
                                              <a class="num" href="">3</a>
                                              <a class="num" href="">489</a>
                                              <a class="next" href="">&gt;&gt;</a></div>
                                      </div>--}}{{--
                             </div>--}}
                </div>
            </div>
        </div>
    </div>
@endsection

@section('tab_js')
    <script>
        layui.use(['form'], function(){
            var form = layui.form;

            //监听指定开关-修改状态
            form.on('switch(change_state)',
                function(obj){
                    change_state(this);
                    // layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                    //     offset: '60px'
                    // });
                    // layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', obj.othis)
                });

            // 分类展开收起的分类的逻辑
            //
            $(function(){
                $("tbody.x-cate tr[fid!='0']").hide();
                // 栏目多级显示效果
                $('.x-show').click(function () {
                    if($(this).attr('status')=='true'){
                        $(this).html('&#xe625;');
                        $(this).attr('status','false');
                        cateId = $(this).parents('tr').attr('cate-id');
                        $("tbody tr[fid="+cateId+"]").show();
                    }else{
                        cateIds = [];
                        $(this).html('&#xe623;');
                        $(this).attr('status','true');
                        cateId = $(this).parents('tr').attr('cate-id');
                        getCateId(cateId);
                        for (var i in cateIds) {
                            $("tbody tr[cate-id="+cateIds[i]+"]").hide().find('.x-show').html('&#xe623;').attr('status','true');
                        }
                    }
                })
            });

            var cateIds = [];
            function getCateId(cateId) {
                $("tbody tr[fid="+cateId+"]").each(function(index, el) {
                    id = $(el).attr('cate-id');
                    cateIds.push(id);
                    getCateId(id);
                });
            }
        });
    </script>
@endsection




